package reflection;

public class Test02 {
    public static void main(String[] args) throws ClassNotFoundException {
        //获得系统类的类加载器
        final ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader();
        System.out.println(systemClassLoader);

        //系统类加载器的父类加载器 --> 扩展类加载器
        final ClassLoader parent = systemClassLoader.getParent();
        System.out.println(parent);

        //获得扩展类加载器的父类加载器 --> 根加载器（c/c++），java程序是获取不到的
        final ClassLoader parent1 = parent.getParent();
        System.out.println(parent1);

    //    测试当前类是哪个类加载器加载的
        final ClassLoader classLoader = Test02.class.getClassLoader();
        System.out.println(classLoader);

        //测试JDK内置的类是谁加载的
        final ClassLoader classLoader1 = Class.forName("java.lang.Object").getClassLoader();
        System.out.println(classLoader1);

    //    如何获得系统类加载器可以加载的路径
        System.out.println(System.getProperty("java.class.path"));

        /**
         * 下面是系统类加载器加载的类，如果类不在这些地方，就不会被加载
         * C:\Program Files\Java\jdk1.8.0_241\jre\lib\charsets.jar;
         * C:\Program Files\Java\jdk1.8.0_241\jre\lib\deploy.jar;
         * C:\Program Files\Java\jdk1.8.0_241\jre\lib\ext\access-bridge-64.jar;
         * C:\Program Files\Java\jdk1.8.0_241\jre\lib\ext\cldrdata.jar;
         * C:\Program Files\Java\jdk1.8.0_241\jre\lib\ext\dnsns.jar;
         * C:\Program Files\Java\jdk1.8.0_241\jre\lib\ext\jaccess.jar;
         * C:\Program Files\Java\jdk1.8.0_241\jre\lib\ext\jfxrt.jar;
         * C:\Program Files\Java\jdk1.8.0_241\jre\lib\ext\localedata.jar;
         * C:\Program Files\Java\jdk1.8.0_241\jre\lib\ext\nashorn.jar;
         * C:\Program Files\Java\jdk1.8.0_241\jre\lib\ext\sunec.jar;
         * C:\Program Files\Java\jdk1.8.0_241\jre\lib\ext\sunjce_provider.jar;
         * C:\Program Files\Java\jdk1.8.0_241\jre\lib\ext\sunmscapi.jar;
         * C:\Program Files\Java\jdk1.8.0_241\jre\lib\ext\sunpkcs11.jar;
         * C:\Program Files\Java\jdk1.8.0_241\jre\lib\ext\zipfs.jar;
         * C:\Program Files\Java\jdk1.8.0_241\jre\lib\javaws.jar;
         * C:\Program Files\Java\jdk1.8.0_241\jre\lib\jce.jar;
         * C:\Program Files\Java\jdk1.8.0_241\jre\lib\jfr.jar;
         * C:\Program Files\Java\jdk1.8.0_241\jre\lib\jfxswt.jar;
         * C:\Program Files\Java\jdk1.8.0_241\jre\lib\jsse.jar;
         * C:\Program Files\Java\jdk1.8.0_241\jre\lib\management-agent.jar;
         * C:\Program Files\Java\jdk1.8.0_241\jre\lib\plugin.jar;
         * C:\Program Files\Java\jdk1.8.0_241\jre\lib\resources.jar;
         * C:\Program Files\Java\jdk1.8.0_241\jre\lib\rt.jar;
         * 可以获得自己写的类
         * D:\Users\巧啡豆\IdeaProjects\myProjects\java-reflection\target\classes;
         * D:\Program Files\JetBrains\IntelliJ IDEA 2021.1\lib\idea_rt.jar
         */
    }
}
